#!/bin/bash 
set -e


TMP=${TMP:-/tmp/work}
LOG=${LOG:-$HOME/logs/stage4}
SRC=${SRC:-/sources}

name=unzip
version=6.0

rm -rf $TMP
mkdir -p $TMP $LOG

tar xf $SRC/$name${version/.}.tar.gz -C $TMP

{ time \
   {

    cd $TMP/$name${version/.}
    
	patch -Np1 -i $SRC/$name-$version-consolidated_fixes-1.patch

	make -f unix/Makefile generic

	make prefix=/usr MANDIR=/usr/share/man/man1 \
	 -f unix/Makefile install

    }
} 2>&1 | tee $name.log
    
[ $PIPESTATUS = 0 ] && mv $name.log $LOG || exit $PIPESTATUS

rm -fr $TMP
